package cc.htdf.gwc.datacompare.job;

import cc.htdf.gwc.datacompare.service.DataCompareService;
import cc.htdf.gwc.datacompare.service.DateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import whisper.common.utils.DateUtils;

import java.util.Date;

/**
 * Created by JT on 2017/10/11.
 */
@Component
public class DataCompareJob {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private DataCompareService compareService;

    @Autowired
    private DateService dateService;

//    @Scheduled(cron = "${job.cron.datacompare}")
    public void excute() {

        logger.info("任务：数据对比任务开始执行，时间：{}", DateUtils.formatDateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"));

        String lastDateCompare = dateService.findLastCompareDate();
        compareService.dataCompare(lastDateCompare);

        logger.info("任务：数据对比任务结束执行，时间：{}", DateUtils.formatDateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"));

    }

}
